<template>
    <van-tabbar v-model="active" active-color="rgb(87, 190, 218)" @change="changeTab" route fixed>
        <van-tabbar-item replace to="/index">
            <span>首页</span>
            <template #icon="props">
                <img :src="props.active ? icon1.active : icon1.inactive" />
            </template>
        </van-tabbar-item>
        <van-tabbar-item v-if="showSnapshot">
            <eagle-image-upload :image="require('@/assets/icons/icon_nav_snapshot2.png')" @after-read="afterRead">
            </eagle-image-upload>
        </van-tabbar-item>
        <van-tabbar-item replace to="/my">
            <span>我的</span>
            <template #icon="props">
                <img :src="props.active ? icon2.active : icon2.inactive" />
            </template>
        </van-tabbar-item>
    </van-tabbar>
</template>

<script>
import { upload } from "@/api/common";
export default {
    props: {
        showSnapshot: {
            type: Boolean,
            default: true,
        },
    },
    data() {
        return {
            active: 2,
            icon1: {
                active: require("../assets/icons/icon_nav_home_on.png"),
                inactive: require("../assets/icons/icon_nav_home_off.png"),
            },
            icon2: {
                active: require("../assets/icons/icon_nav_my_on.png"),
                inactive: require("../assets/icons/icon_nav_my_off.png"),
            },
            fileList: [],
            isJG:false
        };
    },
    created(){
        this.isJG= this.$store.state.CompanyType=='JG'
    },
    methods: {
        changeTab(val) {
            this.active = val;
        },
        // 上传图片
        afterRead(file) {
            let url = this.isJG?"DangerCheckTaskDetailEdit_JG":"DangerCheckTaskDetailEdit"
            // let url = "DangerCheckTaskDetailEdit"
            this.$router.push({
                name: url,
                query: {
                    originType: 3,
                },
                params: {
                    file: file,
                },
            });
        },
        onOversize(file) {
            Toast("文件大小不能超过 2M");
        },
    },
};
</script>

<style lang="less" scope>
.van-tabbar-item .upload-img {
    width: 40px;
    height: 35px;
}
</style>